/*
 *
 *
 */

#ifndef KEY_COMMON_H
#define KEY_COMMON_H

#include "gkt_debug.h"
#include "gkt_event.h"
#include "gkt_key.h"

#define KEY_F_CALIBRATE_BUSY	(1U << 0)
#define KEY_F_CALIBRATE_DONE	(1U << 1)
#define KEY_F_FIRST_VALID	(1U << 4)
#define KEY_F_LED_ENABLE	(1U << 8)
#define KEY_F_LED_FLICKING	(1U << 16)

#define KEY_LED_MARQUEE_FRAME_MINNUMS	2
#ifdef GKT_CONFIG_KEY_LED_MARQUEE_FRAME_MAXNUMS
#define KEY_LED_MARQUEE_FRAME_MAXNUMS	\
	GKT_CONFIG_KEY_LED_MARQUEE_FRAME_MAXNUMS
#else
#define KEY_LED_MARQUEE_FRAME_MAXNUMS	12
#endif
#if (KEY_LED_MARQUEE_FRAME_MAXNUMS < KEY_LED_MARQUEE_FRAME_MINNUMS)
#error "marquee frame maxnums should >= minnums"
#endif

typedef struct _key_manage {
	uint32_t flags;
	uint32_t	seq;
	uint32_t	unmask_bits;
	uint32_t	all_on_counter;
#ifdef GKT_CONFIG_KEY_LED_MAP_TABLE
	uint32_t	on_key_bits;
	uint32_t	on_led_bits;
	uint32_t	all_led_bits;
	uint32_t	frames_led_bits[KEY_LED_MARQUEE_FRAME_MAXNUMS];
#endif
	uint32_t	wakeup_key;
	uint32_t	long_press_bits;

	gkt_key_default_handler	def_handlers[GKT_KEY_MAX];
} key_manage_s;
extern key_manage_s g_key_manage;

#ifdef GKT_CONFIG_KEY_LED_MAP_TABLE
void key_led_init(void);
#else
#define key_led_init()	do { } while(0)
#endif

#if defined(GKT_CONFIG_VOICE_OUTPUT_ENABLE) && GKT_CONFIG_VOICE_OUTPUT_ENABLE
void key_voice_init(void);
void key_voice_play(uint32_t key_value, uint32_t type);
#else
#define key_voice_init()	do {} while(0)
#define key_voice_play(key_value, type)	do {} while(0)
#endif

#endif	/* KEY_COMMON_H */

